import 'package:flutter/material.dart';
import '../widgets/custom_card.dart';
import '../widgets/rounded_button.dart';
import '../utils/app_colors.dart';

class HomeScreen extends StatelessWidget {
  const HomeScreen({super.key});

  void _showDialog(BuildContext context) {
    showDialog(
        context: context,
        builder: (context) => AlertDialog(
              title: const Text('Material Dialog'),
              content: const Text(
                  'This is a Material Design dialog with custom styling.'),
              actions: [
                TextButton(
                    onPressed: () => Navigator.pop(context),
                    child: Text('Cancel')),
                ElevatedButton(
                    onPressed: () {
                      Navigator.pop(context);
                      ScaffoldMessenger.of(context)
                          .showSnackBar(
                        SnackBar(content: const Text('Action confirmed!'),
                              backgroundColor: AppColors.snackbarBackground,
                          behavior: SnackBarBehavior.floating,
                          shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
                        ));
                    },
                    style: ElevatedButton.styleFrom(backgroundColor: AppColors.primary),
                    child: const Text('Confirm', style: TextStyle(color: Colors.white)),
                ),
              ],
            ));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Material Components Demo'),
        backgroundColor: AppColors.primary,
      ),
      body: Padding(
        padding: const EdgeInsets.all(16),
        child: Column(
          children: [
            const CustomCard(),
            const SizedBox(height: 24),
            RoundedButton(text: 'show Dialog',
                onPressed: ()=>_showDialog(context)),
            const SizedBox(height: 16),
            RoundedButton(text:  'Show SnackBar',
                onPressed: ()=>{
              ScaffoldMessenger.of(context).showSnackBar(
                  SnackBar(
                    content: const Text('This is a SnackBar norification'),
                    backgroundColor: AppColors.snackbarBackground,
                    action: SnackBarAction(
                      label: 'Dismiss',
                      textColor: AppColors.accent,
                      onPressed: (){
                        print("dismiss dialog");
                      },
                    ),
                  ))
                })
          ],
        ),
      ),
    );
  }
}
